package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	res, err := http.Get("https://www.baidu.com")
	if err != nil {
		fmt.Println("http get error", err)
		return
	}
	defer res.Body.Close()

	buf := make([]byte, 4096)
	var result string
	for {
		n, err := res.Body.Read(buf)

		result += string(buf[:n])

		if err == io.EOF {
			break
		}
		if n == 0 {
			fmt.Println("read err", err)
			break
		}
		if err != nil {
			fmt.Println("read error", err)
			break
		}
	}

	fmt.Println(result)
}
